package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.Dish;
import com.itheima.reggie.entity.ShoppingCart;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ShoppingCartMapper {
    //查询所有
    @Select("select * from shopping_cart where user_id=#{userId}")
    List<ShoppingCart> findAll(Long userId);
    //加入购物车
    @Insert("insert into shopping_cart values(null,#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime})")
    Integer add(ShoppingCart shoppingCart);
    //清空购物车
    Integer deleteByIds(@Param("userId") Long userId);
    //判断购物车中是否已存在指定商品
    ShoppingCart findByNameAndUserId(ShoppingCart shoppingCart);
    //更新购物车商品数量
    Integer updateNumber(ShoppingCart shoppingCart);
    //删除购物车指定商品
    Integer deleteById(ShoppingCart shoppingCart);
}
